TableGroups='grup'
ColumnGID='GID'

TableUsers='member'
ColumnUID_alpha='ID'
ColumnUID_num='UID'
ColumnEmail='email'

TableLabels="label"
ColumnLabelID="ID"


function sqlQueryAllGroups()
{
	sqlSelectColumn "${TableGroups}" "${ColumnGID}"
}



function sqlQueryAllUsersUID_alpha()
{
	sqlSelectColumn "${TableGroups}" "${ColumnUID_alpha}"
}

function sqlQueryAllUsersUID_num()
{
	sqlSelectColumn "${TableGroups}" "${ColumnUID_num}"
}


function sqlQueryOneUser()
{
	sqlSelectLine "${TableUsers}" "${ColumnUID_alpha}" "${1}"
}


function sqlQueryOneUserEmail()
{
	sqlSelectItem "${TableUsers}" "${ColumnUID_alpha}" "${1}" "${ColumnEmail}"
}

function sqlAddLabel()
{
	sqlInsert "${TableLabels}" "${ColumnLabelID}" "${1}"
}

function sqlModifyLabel()
{
 	ThisLang="${1}"
	ThisLabel="${2}"
	ThisValue="${3}"
	sqlUpdate "${TableLabels}" "${ColumnLabelID}" "${ThisLabel}" "${ThisLang}" "${ThisValue}"
}


function sqlSelectColumn()
{
	sqlRequest "SELECT \`${2}\` FROM \`${1}\`;"
}

function sqlSelectLine()
{
	sqlRequest "SELECT * FROM \`${1}\` where \`${2}\` like '${3}';"
}


function sqlSelectItem()
{
	sqlRequest "SELECT \`${4}\` FROM \`${1}\` where \`${2}\` like '${3}';"
}



function sqlInsert()
{
	ThisTable=${1}
	ThisElement=${2}
	ThisValue=${3}

	sqlRequest "INSERT INTO \`${ThisTable}\` (\`${ThisElement}\`) VALUES ('${ThisValue}');"
}



function sqlUpdate()
{
	ThisTable=${1}
	ThisColumn=${2}
	ThisElement=${3}
	ThisField=${4}
	ThisValue=${5}

	sqlRequest "UPDATE \`${ThisTable}\` SET \`${ThisField}\` = '${ThisValue}' WHERE CONVERT( \`${ThisColumn}\` USING utf8 ) = '${ThisElement}';"
}



function sqlRequest()
{
	echo "${1}" | mysql --user=master2007 --password=2007 agora
}








